<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="prc.*" %>  
<jsp:include page="top.jsp"/>
<% if(!(UserManagement.getUserByUsername(session.getAttribute("loggedUser").toString()).getGroup().equals("admin"))) response.sendRedirect("index.jsp");  %>
	<div id="page-body">
<div class="panel">
	<div class="inner">
	<h2>Forum - Categorie noua</h2>
	<fieldset class="fields2">
	<dl>
		<form method="post" action="addCategorie.jsp" id="register">
		<dt><label for="username">Nume Categorie:</label><br></dt>
		<dd><input type="text" tabindex="1" name="nume" id="nume" size="25" value="" class="inputbox autowidth" title="Nume"></dd>
		<dd><input  type="submit" tabindex="9" name="submit" id="submit" value="Add" class="button1 default-submit-action"></dd>
		</form>
	</dl>
	</fieldset>
	<% 
		String selectedCategory=request.getParameter("categorie"); 
		if(selectedCategory==null&&ForumManagement.categorii.size()!=0)
			selectedCategory=ForumManagement.categorii.get(0).getNume();
	%>	
	<% if(selectedCategory!=null){ %>
	<h2>Forum - Editeaza categorie <% if(selectedCategory!=null) out.print("- "+selectedCategory); %></h2>

			<fieldset class="fields2">
			<dl>
				<form method="get" action="forumAdmin.jsp" >
				<dt><label for="username">Selecteaza Categorie:</label><br></dt>
				<select name="categorie"  class="inputbox autowidth"  onchange='this.form.submit()' >
				<% 
					
		
					int i;
					for(i=0;i<ForumManagement.categorii.size();i++){
						
						String nume=ForumManagement.categorii.get(i).getNume();
						String selected="";  
						if(selectedCategory!=null&&selectedCategory.equals(nume)){
							selected="selected";
							
						}
						out.println("<option value=\""+nume+"\"  "+ selected +">"+nume+"</option>");
					}
					
				%>
					
				</select>
				</form>
			</dl>
			</fieldset>	

			<fieldset class="fields2">
			<dl>
			<dt><label for="username">Sectiuni:</label><br></dt>
			</dl>
			<dl>
			<%
				Categorie c=ForumManagement.getCategByName(selectedCategory);
				for(i=0;i<c.sectiuni.size();i++)
					out.print("<dl><dt>"+c.sectiuni.get(i).getNume()+"</dt></dl>");
			%>

				<hr>
				<form method="get" action="addSectiune.jsp" >
				<dt><label for="username">Nume Sectiune:</label><br></dt>
				<dd><input type="text" tabindex="1" name="nume" id="nume" size="25" value="" class="inputbox autowidth" title="Nume"></dd>
				<dd><input  type="submit" name="submit" value="Add s" class="button1 default-submit-action"></dd>
				<dd><input type="hidden" name="categorie" value="<% out.print(selectedCategory); %>" >
				</form>
			</dl>
			</fieldset>
		
		<% } %>
	

</div>	



</div>
	
<jsp:include page="bottom.jsp"/>